package com.situ.day23.factory;

import org.junit.Test;

import java.io.IOException;

public class CalDemo {
    //Client
    @Test
    public void test1() {
        //Cal cal = new Add();
        Cal cal = CalFactory.createCal1("+");
        cal.setNumA(3);
        cal.setNumB(5);
        System.out.println(cal.getResult());

        //Cal cal = new Sub();
        cal = CalFactory.createCal1("-");
        cal.setNumA(3);
        cal.setNumB(5);
        System.out.println(cal.getResult());
    }

    @Test
    public void test2() throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException {
        //Cal cal = new Add();
        Cal cal = CalFactory.createCal();
        cal.setNumA(3);
        cal.setNumB(5);
        System.out.println(cal.getResult());

    }
}
